package com.azzcs.rocketmq.service.listener;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author: wzg
 * @Date: 2021/4/29 上午5:44
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "phone-topic",consumerGroup = "c_g_01")
public class PhoneListener implements RocketMQListener<String> {
    AtomicInteger num = new AtomicInteger(0);
    @Override
    public void onMessage(String s) {
        int i = num.incrementAndGet();
        log.info("用户："+s+",抢购到了第"+i+"部手机");
    }
}
